package com.fitso.model.bean.nutrition;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

import com.fitso.model.bean.measure.energy.Calorie;
import com.fitso.model.bean.measure.mass.Mass;

/**
 * <p>
 * Trace {@link Nutrient} compound required by organims.
 * </p>
 * 
 * @author timothy storm
 * @see <a href="http://en.wikipedia.org/wiki/Mineral">Mineral</a>
 */
public class Minerals extends Nutrient implements Serializable {
	// Only change on breaking changes, i.e., removing fields
	private static final long serialVersionUID = 1L;
	
	private Mass _boron, _calcium, _chloride, _chromium, _copper, _iodine, _iron, _manganese, _magnesium, _molybdenum,
			_nickel, _phosphorus, _potassium, _selenium, _silicon, _sodium, _tin, _vanadium, _zinc;

	public Minerals() {}

	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (o == this) {
			return true;
		}
		if (o.getClass() != getClass()) {
			return false;
		}

		Minerals other = (Minerals) o;
		return new EqualsBuilder().append(_calcium, other._calcium).append(_chloride, other._chloride).append(
				_chromium, other._chromium).append(_copper, other._copper).append(_iodine, other._iodine).append(_iron,
				other._iron).append(_manganese, other._manganese).append(_magnesium, other._magnesium).append(
				_molybdenum, other._molybdenum).append(_phosphorus, other._phosphorus).append(_potassium,
				other._potassium).append(_selenium, other._selenium).append(_sodium, other._sodium).append(_zinc,
				other._zinc).isEquals();
	}

	public Mass getBoron() {
		return _boron;
	}

	public Mass getCalcium() {
		return _calcium;
	}

	/**
	 * There is no measurable amount of energy provided by vitamins or minerals
	 */
	protected Calorie getCaloriesPerGram() {
		return new Calorie(0.0);
	}

	public Mass getChloride() {
		return _chloride;
	}

	public Mass getChromium() {
		return _chromium;
	}

	public Mass getCopper() {
		return _copper;
	}

	public Mass getIodine() {
		return _iodine;
	}

	public Mass getIron() {
		return _iron;
	}

	public Mass getMagnesium() {
		return _magnesium;
	}

	public Mass getManganese() {
		return _manganese;
	}

	public Mass getMolybdenum() {
		return _molybdenum;
	}

	public Mass getNickel() {
		return _nickel;
	}

	public Mass getPhosphorus() {
		return _phosphorus;
	}

	public Mass getPotassium() {
		return _potassium;
	}

	public Mass getSelenium() {
		return _selenium;
	}

	public Mass getSilicon() {
		return _silicon;
	}

	public Mass getSodium() {
		return _sodium;
	}

	public Mass getTin() {
		return _tin;
	}

	public Mass getVanadium() {
		return _vanadium;
	}

	public Mass getZinc() {
		return _zinc;
	}

	public int hashCode() {
		return new HashCodeBuilder().append(_calcium).append(_chloride).append(_chromium).append(_copper).append(
				_iodine).append(_iron).append(_manganese).append(_magnesium).append(_molybdenum).append(_phosphorus)
				.append(_potassium).append(_selenium).append(_sodium).append(_zinc).toHashCode();
	}

	public void setBoron(Mass boron) {
		_boron = boron;
	}

	public void setCalcium(Mass calcium) {
		_calcium = calcium;
	}

	public void setChloride(Mass chloride) {
		_chloride = chloride;
	}

	public void setChromium(Mass chromium) {
		_chromium = chromium;
	}

	public void setCopper(Mass copper) {
		_copper = copper;
	}

	public void setIodine(Mass iodine) {
		_iodine = iodine;
	}

	public void setIron(Mass iron) {
		_iron = iron;
	}

	public void setMagnesium(Mass magnesium) {
		_magnesium = magnesium;
	}

	public void setManganese(Mass manganese) {
		_manganese = manganese;
	}

	public void setMolybdenum(Mass molybdenum) {
		_molybdenum = molybdenum;
	}

	public void setNickel(Mass nickel) {
		_nickel = nickel;
	}

	public void setPhosphorus(Mass phosphorus) {
		_phosphorus = phosphorus;
	}

	public void setPotassium(Mass potassium) {
		_potassium = potassium;
	}

	public void setSelenium(Mass selenium) {
		_selenium = selenium;
	}

	public void setSilicon(Mass silicon) {
		_silicon = silicon;
	}

	public void setSodium(Mass sodium) {
		_sodium = sodium;
	}

	public void setTin(Mass tin) {
		_tin = tin;
	}

	public void setVanadium(Mass vanadium) {
		_vanadium = vanadium;
	}

	public void setZinc(Mass zinc) {
		_zinc = zinc;
	}

	public String toString() {
		return new ReflectionToStringBuilder(this).toString();
	}

	public Mass[] getAllMinerals() {
		List<Mass> minerals = new ArrayList<Mass>();
		minerals.add(_boron);
		minerals.add(_calcium);
		minerals.add(_chloride);
		minerals.add(_chromium);
		minerals.add(_copper);
		minerals.add(_iodine);
		minerals.add(_iron);
		minerals.add(_manganese);
		minerals.add(_magnesium);
		minerals.add(_molybdenum);
		minerals.add(_nickel);
		minerals.add(_phosphorus);
		minerals.add(_potassium);
		minerals.add(_selenium);
		minerals.add(_silicon);
		minerals.add(_sodium);
		minerals.add(_tin);
		minerals.add(_vanadium);
		minerals.add(_zinc);
		return minerals.toArray(new Mass[minerals.size()]);
	}
}
